//
//  WBStatusCell.swift
//  Weibo
//
//  Created by yinbo on 2018/3/19.
//  Copyright © 2018年 yinbo. All rights reserved.
//

import UIKit

class WBStatusCell: UITableViewCell {
    //头像
    @IBOutlet weak var iconView: UIImageView!
    //姓名
    @IBOutlet weak var nameLab: UILabel!
    //会员图标
    @IBOutlet weak var memberIconView: UIImageView!
    //时间
    @IBOutlet weak var timeLabel: UILabel!
    //来源
    @IBOutlet weak var sourceLabel: UILabel!
    //认证图标
    @IBOutlet weak var vipIconView: UIImageView!
    
    //正文
    @IBOutlet weak var statusLabel: UILabel!
    
    @IBOutlet weak var picTopCons: NSLayoutConstraint!
    
    @IBOutlet weak var toolBar: WBStatusToolBar!
    @IBOutlet weak var pictureView: WBStatusPictureView!

    //被转发微博的表情 -原创微博没有此控件，一定要用？
    
    @IBOutlet weak var retweetedLab: UILabel?
    
    var viewModel:WBStatusViewModel?{
        didSet{
            nameLab.text = viewModel?.status.user?.screen_name
            statusLabel.text = viewModel?.status.text
            memberIconView.image=viewModel?.memberIcon
            vipIconView.image = viewModel?.vipIcon
            
            iconView.cz_setImage(urlString: viewModel?.status.user?.profile_image_url, placeholderImage: UIImage(named:"avatar_default_big"),isAvator: true)
            toolBar.viewModel = viewModel
            //测试修改配图视图高度
//            picTopCons.constant = 0
            
            pictureView.viewModel = viewModel
//            pictureView.heightCons.constant = viewModel?.pictureViewSize.height ?? 0
//            pictureView.urls = viewModel?.picURLs
            retweetedLab?.text = viewModel?.retweetedText
            
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        //离屏渲染-异步绘制
        self.layer.drawsAsynchronously = true
        //珊格化-异步绘制之后，会生成一张独立的图片，cell在屏幕上滚动的时候，本质上滚动的是这种图片
        //cell优化，要尽量减少图层的数量，相当于就只有一层！
        //停止滚动之后，可以接收监听
        self.layer.shouldRasterize = true
        //使用“栅格化”必须注意指定分辨率
        self.layer.rasterizationScale = UIScreen.main.scale
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
